<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>计算器</title>
</head>
<body>
    <div>
        <input type="text" id="num1">
        <select id="operator">
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
        </select>
        <input type="text" id="num2">
        <button id="calculate">计算</button>
        <input type="text" id="result" disabled>
    </div>
    <script>
        document.getElementById('calculate').onclick = function(){
            var num1 = document.getElementById('num1').value;
            var num2 = document.getElementById('num2').value;
            var operator = document.getElementById('operator').value;
            var result;
            switch(operator){
                case "+":
                    result = parseFloat(num1) + parseFloat(num2);
                    break;
                case "-":
                    result = parseFloat(num1) - parseFloat(num2);
                    break;
                case "*":
                    result = parseFloat(num1) * parseFloat(num2);
                    break;
                case "/":
                    result = parseFloat(num1) / parseFloat(num2);
                    break;
            }
            document.getElementById('result').value = result;
        }
    </script>
</body>
</html>
